﻿var eventId;
var eventName;
var sessionId;
$(function () {
    sessionId = querySt('id');
    ajaxCall('DataService.asmx/GetVideoUrl', false, "{'sessionId':'" + sessionId + "'}",
                function (msg) {
                    $('#MediaPlayer').append('<param name="autoStart" value="False" /><embed id="vidId" type="application/x-mplayer2" src="' + msg.d + '" name="MediaPlayer" width="570" height="300"></embed> ');
                    $('#vidId').attr('src', msg.d);
                },
                function () {
                    alert("Error happend while reading video url!");
                }
            );

    ajaxCall('../DataService.asmx/GetSessionById', false, '{"id":"' + sessionId + '"}',
                function (msg) {
                    var speakers = msg.d.Speakers[0].FirstName + " " + msg.d.Speakers[0].LastName;
                    for (var j = 1; j < msg.d.Speakers.length; j++) {
                        speakers = speakers + ", " + msg.d.Speakers[j].FirstName + " " + msg.d.Speakers[j].LastName;
                    }
                    $('#lblPresentationName').html(msg.d.Title);
                    $('#descriptionDiv').html(msg.d.Description);
                    $('#lkSpeakers').html(speakers);
                    $('#lkDownloadPPT').attr('href', 'GetPresentationForSession.ashx?id=' + sessionId);
                    $('#lkDownloadVideo').attr('href', 'GetVideoForSession.ashx?id=' + sessionId);
                    $('#lkDownloadSource').attr('href', 'GetSourseForSession.ashx?id=' + sessionId);
                    
                    if (msg.d.FinishedSessionImages != "") {
                        $('#slideShowDiv').append(msg.d.FinishedSessionImages);
                    } 
                    else {
                        $('#slideShowDiv').append("<label style='color:red; font-weight:bold;'>Skydrive album not found!</label>");
                        $('#slideShowDiv').append("<br/>");
                        $('#slideShowDiv').append("<br/>");
                    }
                    eventId = msg.d.EventID;
                },

                function () {
                    alert("Error happend while reading data from database");
                }
            );

    ajaxCall('../DataService.asmx/GetEventById', false, '{"id":"' + eventId + '"}',
                function (msg) {
                    eventName = msg.d.EventName;
                    $('#lblEventName').html(eventName);
                    $('#lblEventNameSmall').html(eventName);
                },
                function () {
                    alert("Error happend while reading data from database");
                }
            );
});